<template>
  <div>

    <div class="home">
      <h1  style="margin-top:160px;
    margin-left:480px;font-size:4em; ">欢迎!!!</h1>
      <h1 style="margin-left:360px" > 请选择导航栏功能开始使用...</h1>
    </div>
  </div>
</template>
<script>
export default {
  name: 'home',

  data () {
    return {
      // in component:
      // 收集表单数据---关键字的
      keyword: ''
    }
  }
  /* mounted(){
/**
          初始化websocket

        this.initWebSocket()
        let	vm = this;
    window.onbeforeunload = function () {
                // vm.send("closesocket:");
                vm.closeWebSocket();
            }
            },
            beforeDestroy(){
                //关闭WebSocket连接
            this.closeWebSocket()

            },
            methods:{
              initWebSocket(){
            // var websocket = null;
            //判断当前浏览器是否支持WebSocket
            if ('WebSocket' in window) {
                var serviceIp ="172.168.0.16:8880";
                this.websocket = new WebSocket("ws://"+serviceIp+"/system/websocket");
            }else if ('MozWebSocket' in window) {
                 var serviceIp ="172.168.0.16:8880";
                 this.websocket = new WebSocket("ws://"+serviceIp+"/system/websocket");
           }
            else {
                console.log('当前浏览器 Not support websocket');
                let that = this;
                 this.interval = window.setInterval(function(){ //每隔30秒钟发送一次心跳，避免websocket连接因超时而自动断开
                   that.forgeWebSocket();
                },30000);
            }
        let that = this;
        this.interval = window.setInterval(function(){ //每隔30秒钟发送一次心跳，避免websocket连接因超时而自动断开
                    if(that.websocket!=null){
                        that.websocket.send("HeartBeat");
                        console.log("发送心跳包：HeartBeat");
                    }
                },30000);

            //连接发生错误的回调方法
            this.websocket.onerror = function (ev) {
                console.log("WebSocket连接发生错误");
            };

            //连接成功建立的回调方法
            this.websocket.onopen = function (ev) {
                console.log("WebSocket连接成功");
                this.send("addsocket");
            }

            //接收到消息的回调方法
            this.websocket.onmessage = function (event) {
                console.log(event.data);
            }

            //连接关闭的回调方法
            this.websocket.onclose = function (ev) {
                console.log("WebSocket连接关闭");
                this.websocket=null;
            }
        },

            send(message){
                if(this.websocket && this.websocket != null){
                this.websocket.send(message);
                console.log("发送的消息："+message);
                }
            },
            //关闭WebSocket连接
            closeWebSocket() {
                if(this.websocket != null){
                this.websocket.close();
                console.log("已执行closeWebSocket中关闭websocket操作");
                }
                if(this.interval){
                    window.clearInterval(this.interval);
                    console.log("清除定时器");
                }
            },
            } */

}

</script>
<style lang="less"scoped>
div {
  width: 1114px;
  margin: 0 auto;
  height: 590px;
  overflow: hidden;
  background-image: url(./images/csy.jpg);
  color: rgb(53, 52, 52);
}
</style>
